package com.example.rouroudate.util

import android.app.Activity
import android.content.Context
import android.content.pm.PackageManager
import androidx.core.app.ActivityCompat

object PermissionUtils {
    fun checkPermission(activity: Activity, checkList: Array<String>): Array<String> {
        val list = ArrayList<String>()
        for ((i, _) in checkList.withIndex()) {
            if (PackageManager.PERMISSION_GRANTED != ActivityCompat.checkSelfPermission(activity, checkList[i])) {
                list.add(checkList[i]);
            }
        }
        return list.toTypedArray()
    }

    fun requestPermission(activity: Activity, permissionList: Array<String>, requestCode: Int) {
        ActivityCompat.requestPermissions(activity, permissionList, requestCode)
    }
}